/* eslint-disable */
import Vue from 'vue'
import Router from 'vue-router'
import store from './store.js'

Vue.use(Router)
const router = new Router({
  routes: [
    {
      path: '/',
      name: 'login',
      component: () => import('./views/Login.vue')
    },
    {
      path: '/home',
      name: 'mainLayout',
      component: () =>
        import(/* webpackChunkName: "layout" */ './layout/MainLayout.vue'),
      redirect: '/home/index',
      children: [
        {
          path: '/home/index',
          name: 'index',
          component: () => import('./views/home/Index.vue')
        },
        {
          path: '/home/description',
          name: 'description',
          component: () => import('./views/home/Description.vue'),
          children: [
            {
              path: '/home/description/purpose',
              name: 'purpose',
              component: () => import('./views/home/description/Purpose.vue')
            },
            {
              path: '/home/description/example',
              name: 'example',
              component: () => import('./views/home/description/Example.vue')
            },
            {
              path: '/home/description/guide',
              name: 'guide',
              component: () => import('./views/home/description/Guide.vue')
            },
            {
              path: '/home/description/method',
              name: 'method',
              component: () => import('./views/home/description/Method.vue')
            },
            {
              path: '/home/description/platForm',
              name: 'platForm',
              component: () => import('./views/home/description/PlatForm.vue')
            },
            {
              path: '/home/description/sepecial',
              name: 'sepecial',
              component: () => import('./views/home/description/Sepecial.vue')
            },
            {
              path: '/home/description/theory',
              name: 'theory',
              component: () => import('./views/home/description/Theory.vue')
            }
          ]
        },
        {
          path: '/home/experimentalData',
          name: 'experimentalData',
          component: () => import('./views/home/ExperimentalData.vue'),
          children: [
            {
              path: 'home/experimentalData/experimentalAdvice',
              name: 'experimentalAdvice',
              redirect: () => {
                var roleId = store.state.user.roleId
                if (roleId === 1) {
                  return {
                    name: 'experimentalAdviceAdmin'
                  }
                }
                if (roleId === 2) {
                  return {
                    name: 'experimentalAdviceTeacher'
                  }
                }
                return {
                  name: 'experimentalAdviceNormal'
                }
              }
            },
            {
              path: 'home/experimentalData/experimentalAnswer',
              name: 'experimentalAnswer',
              redirect: () => {
                var roleId = store.state.user.roleId
                if (roleId === 1) {
                  return {
                    name: 'experimentalAnswerAdmin'
                  }
                }
                if (roleId === 2) {
                  return {
                    name: 'experimentalAnswerTeacher'
                  }
                }
                return {
                  name: 'experimentalAnswerNormal'
                }
              }
            },
            {
              path: 'home/experimentalData/experimentalRecord',
              name: 'experimentalRecord',
              redirect: () => {
                var roleId = store.state.user.roleId
                if (roleId === 1) {
                  return {
                    name: 'experimentalRecordAdmin'
                  }
                }
                if (roleId === 2) {
                  return {
                    name: 'experimentalRecordTeacher'
                  }
                }
                return {
                  name: 'experimentalRecordNormal'
                }
              }
            },
            {
              path: 'home/experimentalData/experimentCourse',
              name: 'experimentCourse',
              redirect: () => {
                var roleId = store.state.user.roleId
                if (roleId === 1 || roleId === 2) {
                  return {
                    name: 'experimentCourseAdminOrTeacher'
                  }
                }
                return {
                  name: 'experimentCourseNormal'
                }
              }
            },
            {
              path: 'home/experimentalData/experimentCourseAdminOrTeacher',
              name: 'experimentCourseAdminOrTeacher',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentCourseAdminOrTeacher.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentCourseNormal',
              name: 'experimentCourseNormal',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentCourseNormal.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalAnswerTeacher',
              name: 'experimentalAnswerTeacher',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalAnswerTeacher.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalAnswerAdmin',
              name: 'experimentalAnswerAdmin',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalAnswerAdmin.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalAnswerNormal',
              name: 'experimentalAnswerNormal',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalAnswerNormal.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalAdviceAdmin',
              name: 'experimentalAdviceAdmin',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalAdviceAdmin.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalAdviceNormal',
              name: 'experimentalAdviceNormal',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalAdviceNormal.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalAdviceTeacher',
              name: 'experimentalAdviceTeacher',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalAdviceTeacher.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalRecordAdmin',
              name: 'experimentalRecordAdmin',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalRecordAdmin.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalRecordNormal',
              name: 'experimentalRecordNormal',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalRecordNormal.vue'
                )
            },
            {
              path: 'home/experimentalData/experimentalRecordTeacher',
              name: 'experimentalRecordTeacher',
              component: () =>
                import(
                  './views/home/experimentalData/ExperimentalRecordTeacher.vue'
                )
            },
            {
              path: 'home/experimentalData/userManagement',
              name: 'userManagement',
              component: () =>
                import('./views/home/experimentalData/UserManagement.vue')
            }
          ]
        },
        {
          path: '/home/netWorkRequirement',
          name: 'detWorkRequirement',
          component: () => import('./views/home/NetWorkRequirement.vue')
        },
        {
          path: '/home/applyBook',
          name: 'applyBook',
          component: () => import('./views/home/ApplyBook.vue'),
          children: [
            {
              path: 'home/applyBook/apply',
              name: 'apply',
              component: () => import('./views/home/applyBook/Applydetail.vue')
            }
          ]
        },
        {
          path: '/home/characteristics',
          name: 'characteristics',
          component: () => import('./views/home/Characteristics.vue'),
          children: [
            {
              path: '/home/characteristics/c1',
              name: 'c1',
              component: () => import('./views/home/characteristics/C1.vue')
            },
            {
              path: '/home/characteristics/c2',
              name: 'c2',
              component: () => import('./views/home/characteristics/C2.vue')
            },
            {
              path: '/home/characteristics/c3',
              name: 'c3',
              component: () => import('./views/home/characteristics/C3.vue')
            },
            {
              path: '/home/characteristics/c4',
              name: 'c4',
              component: () => import('./views/home/characteristics/C4.vue')
            },
            {
              path: '/home/characteristics/c5',
              name: 'c5',
              component: () => import('./views/home/characteristics/C5.vue')
            }
          ]
        },
        {
          path: '/home/servicePlan',
          name: 'servicePlan',
          component: () => import('./views/home/ServicePlan.vue'),
          children: [
            {
              path: 'home/servicePlan/p1',
              name: 'p1',
              component: () => import('./views/home/servicePlan/P1.vue')
            }
            // {
            //   path: 'home/servicePlan/p2',
            //   name: 'p2',
            //   component: () => import('./views/home/servicePlan/P2.vue')
            // },
            // {
            //   path: 'home/servicePlan/p3',
            //   name: 'p3',
            //   component: () => import('./views/home/servicePlan/P3.vue')
            // },
          ]
        },
        {
          path: '/home/serviceTeam',
          name: 'serviceTeam',
          component: () => import('./views/home/ServiceTeam.vue'),
          children: [
            {
              path: '/home/serviceTeam/t1',
              name: 't1',
              component: () => import('./views/home/serviceTeam/T1.vue')
            },
            {
              path: '/home/serviceTeam/t2',
              name: 't2',
              component: () => import('./views/home/serviceTeam/T2.vue')
            }
          ]
        }
      ]
    }
  ]
})
export default router
// router.beforeEach((to, from, next) => {

//   // window.console.log(to);
//   // window.console.log(from);
//   // if(from.name === to.name){
//   //   return;
//   // }
//   window.console.log(to.name);
//   if (to.name !== "login") {
//     let token = localStorage.getItem('token');
//     //第一次进入store并没有定义。所以并没有执行。
//     if (token) {
//       store.commit('resetToken', token);
//       if (store.state.token) {
//         next();
//       } else {
//         router.push({ name: 'login' });
//       }
//     } else {
//       router.push({ name: 'login' });
//     }
//   } else {
//     next();
//   }
// })
